﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<KLS.PPDS.Web.Models.UserViewModel>" %>
<%@ Import Namespace="KLS.PPDS.Resources" %>
<%@ Import Namespace="KLS.PPDS.Utility" %>
<%@ Import Namespace="KLS.PPDS.Utility.Html" %>


    <%using (Html.BeginForm("SaveUserSettings", "User", FormMethod.Post, new { @class = "submitform", @onkeypress = "applyEnter(event);" }))
      {%>

      <fieldset>
    <legend><%:CommonString.UserSettings%></legend>

    <%:Html.HiddenFor(u=>u.User.Id) %>

    <%if(CommonSession.IsUserEditor)
    {%>
     <%:Html.HiddenFor(c => c.User.CompanyId)%>   
     <%:Html.HiddenFor(c => c.User.RoleId)%>   
    <%
    }%>

    <table>
        <tr>
            <td>
                <%:CommonString.Id+":" %>
            </td>
            <td>
                <input disabled="disabled" type="text" value="<%=Model.User.Id==0?"":Model.User.Id.ToString() %>" />
            </td>
        </tr>
        <tr>
            <td >
                <nobr>
                    <%:CommonString.UserName + ":"%>
                </nobr>
                
            </td>
            <td>
                <%:Html.TextBoxFor(u => u.User.UserName, new { @class = "required email", minlength = "3", @maxlength = "50" })%>
            </td>
        </tr>
        <tr>
            <td>
               <%:CommonString.Password + ":"%>
            </td>
            <td>
                <%:Html.TextBoxFor(u => u.User.Password, new { @class = "required", @type = "password", minlength = "3", @maxlength = "50" })%>
            </td>
        </tr>
        <tr>
            <td >
                
                    <%:CommonString.UserFullName + ":"%>
                               
            </td>
            <td>
                <%:Html.TextBoxFor(u => u.User.UserFullName, new { @maxlength = "50" })%>
            </td>
        </tr>
        <tr>
            <td>
               <%:CommonString.PhoneNumber + ":"%>
            </td>
            <td>
                <%:Html.TextBoxFor(u => u.User.PhoneNo, new { @class = "", @maxlength = "50" })%>
            </td>
        </tr>

        <tr>
            <td>
                <%:CommonString.Language + ":"%>
            </td>
            <td>
                <%:Html.DropDownListFor(u => u.User.LanguageId, Model.LanguageList, CommonMessage.SelectLanguage, new { validate = "required:true" })%>
            </td>
        </tr>

        <%if (CommonSession.IsUserSuperAdmin)
{%>
        <tr>
            <td>
                <%:CommonString.UserType + ":"%>
            </td>

            <td>
                
                    <%:Html.DropDownListFor(u => u.User.RoleId, Model.RoleList, CommonMessage.SelectUserType, new { validate = "required:true", @onchange = "OnUserTypeChange(this)" })%>
                
                
            </td>
        </tr>
        <%
}%>
        <%if(CommonSession.IsUserSuperAdmin)
        {
            var company = Model.User.CompanyId > 0 ? (object)new { } : (object)new { @disabled = "disabled" };
              
         %>
            <tr>
                <td>
                     <%:CommonString.Company + ":"%>
                </td>
                <td>
                    <%:Html.DropDownListFor(u => u.User.CompanyId, Model.CompanyList, CommonMessage.SelectCompany, (object)company)%>
                </td>
            </tr>           
           <%   
        }%>
        
        
    </table>
    <table class="buttons-area">
        <tr>
            <td>
            
             <%if (Model.User.Id > 0 && CommonSession.UserId != Model.User.Id) 
              {%>
                
                    <%--<%:Html.DivActionLink(CommonString.Delete, "", new { @class = "delete-button", @onclick = string.Format("AjaxDeleteCallWithFilter('user/DeleteUser?userId={0}')", Model.User.Id) })%>--%>
                    <%:Html.DivActionLink(CommonString.Delete, "", new { @class = "delete-button", @href = string.Format("user/DeleteUser?userId={0}", Model.User.Id), @message=CommonMessage.DeleteUserConfirmation })%>
                
                <%     
              }%>
                
                    <%:Html.DivActionLink(CommonString.Save,"",new {  @class = "AjaxSubmitEast save-button" }) %>
                               
            </td>
        </tr>
    </table>
    </fieldset>
    <%
      }%>